{include file="public/header" select="0" /}
<style>
    .top input {
        border: none;
        text-align: right;
        background-color: transparent;
    }
</style>
<body class="hide-top bgc">
<div class="draw-container">
    <img src="/static/index/img/icon18.png" alt="">
    <div class="draw-content">
        <div class="draw-hd">
            <i class="layui-icon layui-icon-left" onclick="load_href('{:url(\'user/index\')}',2)"></i> 我要转账
        </div>
        <form action="{:url('transfer/save')}" method="post" class="form layui-form">
            <input type="hidden" id="cost" value="{:cache('system')['transfer_cost']}">
            <div class="transfer-content">
                <div class="top">
                    <div class="left">转账账户</div>
                    <select name="account" lay-verify="required" lay-reqtext="请选择账户">
                        <option value="balance">{:get_pay_way('balance')}(余额:{$user.assets.balance})</option>
                    </select>
                </div>
                <ul class="transfer-list">
                    <li>
                        <p>收账会员</p>
                        <input type="text" name="take" id="take" lay-verify="required" lay-reqtext="请输入收账会员手机号"
                               placeholder="请输入收账会员手机号" autocomplete="off">
                    </li>
                    <li class="take_info" style="display: none;">
                        <p>收账会员姓名</p>
                        <input type="text" id="take_nickname" readonly>
                    </li>
                    {if cache('system')['transfer_cost'] > 0}
                    <li>
                        <p>手续费</p>
                        <input type="text" value="{:cache('system')['transfer_cost']*100}%" readonly>
                    </li>
                    {/if}
                    <li>
                        <p>转账金额</p>
                        <input type="number" name="amount" id="amount" lay-verify="required" lay-reqtext="请输入转账金额"
                               placeholder="请输入转账金额" autocomplete="off"
                               onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">
                    </li>
                    <li class="real_amount" style="display: none;">
                        <p>实际到账金额</p>
                        <input type="text" id="real_amount" placeholder="实际到账金额" autocomplete="off" readonly>
                    </li>
                    <li>
                        <p>支付密码</p>
                        <input type="password" name="pay_password" lay-verify="required" lay-reqtext="请输入支付密码"
                               placeholder="请输入支付密码">
                    </li>
                </ul>
            </div>
            <p class="save upd-save" lay-submit lay-filter="save" formObj=".form">确认转账</p>
        </form>
        <div class="flex-center">
            <a href="{:url('transfer/record')}" class="transfer-rec">转账记录
                <img src="/static/index/img/icon20.png" alt="">
            </a>
        </div>
    </div>
</div>
{include file="public/footer" select="0" /}
<script>
    $('#take').blur(function () {
        var value = $(this).val();
        if (value) {
            $.ajax({
                type: 'GET',
                url: '{:url("transfer/verify")}',
                data: {code:value},
                dataType: "json",
                success: function (data) {
                    $("#take_nickname").val(data.result)
                    $(".take_info").show();
                }
            });
        }else{
            $(".take_info").hide();
        }
    });
    $('#amount').blur(function () {
        var value = $(this).val();
        if (value) {
            var cost = $('#cost').val();
            amount = (parseFloat(value) * (1 - parseFloat(cost))).toFixed(2);
            $('#real_amount').val(amount);
            $(".real_amount").show();
        } else {
            $(".real_amount").hide();
        }
    });
</script>
</body>
</html>